-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add query level cache logic #311
Conversation
backend/kernelCI_app/utils.py
Outdated
from datetime import timedelta | ||
import re | ||
|
||
DEFAULT_QUERY_TIME_INTERVAL = {'days': 7} | ||
DEFAULT_QUERY_CACHE = 180 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be an env var right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think in debug this should be 0 also
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Big win, working beautifully!
backend/kernelCI_app/cache.py
Outdated
|
||
def getQueryCache(key, params: dict): | ||
params_hash = __createCacheParamsHash(params) | ||
return cache.get("%s-%s" % (key, hash(params_hash))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you are already hashing the params in __createCacheParamsHash
backend/kernelCI_app/cache.py
Outdated
def setQueryCache(key, params, rows, commit_hash=None, build_id=None, test_id=None, | ||
timeout=DEFAULT_QUERY_CACHE): | ||
params_hash = __createCacheParamsHash(params) | ||
hash_key = "%s-%s" % (key, hash(params_hash)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto about params already being hashed in createCacheParamsHash
backend/kernelCI_app/cache.py
Outdated
print(ex) | ||
|
||
|
||
def __addToLookup(key, value, lookup): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these names are a little confusing
maybe this could be cacheKey
and instead of value
it could be specificPropertyKey
because the value is being used as the key
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good
0a3c547
to
1300532
Compare
just noticed it is removing the view page cache but we still need for the tree listing slow
4060ce4
to
3bf0c53
Compare
backend/kernelCI/settings.py
Outdated
@@ -206,7 +206,7 @@ def __getitem__(self, item): | |||
CSRF_COOKIE_SECURE = False | |||
SECURE_SSL_REDIRECT = False | |||
SECURE_HSTS_SECONDS = 3600 | |||
CACHE_TIMEOUT = 0 | |||
CACHE_TIMEOUT = 60 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we want debug without cache as the default behavior, otherwise it get's annoying to develop since every change will take one minute to reflect
3bf0c53
to
661c702
Compare
bc881b5
to
10158f3
Compare
Creates the basic logic for caching database queries, currently it will only be applied to the slowest query.
Test by going to a tree details page and filtering the tests or boots tabs, the first load should be normal but any other filtering by status should be faster.
Closes: #301